<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
        <a href="index.html">首页</a>
        <a href="javascript:;" onclick="history.forward()">返回下一页</a>
    <input type="text" name="nihao">
    <p id="duanluo" class="duanluo">你好</p>
    <p>你好</p>
    <p>你好</p>
    <p>你好</p>
    <script>
        // 6种写法
        // 获取单个
       var p=document.querySelector('p');
    //    获取多个
        var p1=document.querySelectorAll('p')[0];
        // 通过ID获取
        var p2=document.getElementById('duanluo');
        //通过类去获得       
        var p3=document.getElementsByTagName("p")[0];
         //通过类名去获得
        
         var p4=document.querySelector(".duanluo")
        //  通过name去获得
        var input1=document.getElementsByName('nihao');
            console.log(p);
            console.log(p1);
            console.log(p2);
            console.log(p3);
            console.log(p4);
            console.log(input1);
    </script>
</body>
</html>